#ifndef __2865031_TOOLS_HH__
#define __2865031_TOOLS_HH__

inline unsigned int __strlen(const char * string)
{
    unsigned int res(0);
    const char * ptr(string);
    for(; (ptr && ((*ptr)) != '\0') ; ptr++)
        res++;
    return res;
}

inline void __strcpy(char * destination, const char * source)
{
    const char * src(source);
    char       * dst(destination);

    for(; ((*src) != '\0') ;)
        *(dst++) = *(src++);
    *(dst) = *(src);
}

inline void __strcat(char * destination, const char * source)
{
    unsigned int n(0), t1(__strlen(destination)), t2(__strlen(source));
    char       * res = new char[t1+t2+1];
    const char * src2(source);
    char       * src1(destination), * dst(res);

    for( ; n<t1 ; n++)
        *(dst++) = *(src1++);
    for(n=0 ; n<=t2 ; n++)
        *(dst++) = *(src2++);
    delete [] destination;
    destination = res;
}

inline void setExtensionByName(char * formatName, const char * fileName)
{
    const char * src(fileName);
    char       * dst(formatName);

    for(; (((*src) != '\0') && ((*src) != '.')) ;)
        src++;
    if( (*src) == '.' )
        src++;
    for(; ((*src) != '\0') ;)
        *(dst++) = *(src++);
    *(dst) = *(src);
}

#endif
